﻿
@{
    Layout = null;
}

<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>H+ 后台主题UI框架 - 日历</title>
    <meta name="keywords" content="H+后台主题,后台bootstrap框架,会员中心主题,后台HTML,响应式后台">
    <meta name="description" content="H+是一个完全响应式，基于Bootstrap3最新版本开发的扁平化主题，她采用了主流的左右两栏式布局，使用了Html5+CSS3等现代技术">

    <link rel="shortcut icon" href="favicon.ico">
    <link href="~/Content/Css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="~/Content/Css/font-awesome.css?v=4.4.0" rel="stylesheet">

    <link href="~/Content/Css/plugins/iCheck/custom.css" rel="stylesheet">

    <link href="~/Content/Css/plugins/fullcalendar/fullcalendar.css" rel="stylesheet">
    <link href="~/Content/Css/plugins/fullcalendar/fullcalendar.print.css" rel="stylesheet">

    <link href="~/Content/Css/animate.css" rel="stylesheet">
    <link href="~/Content/Css/style.css?v=4.1.0" rel="stylesheet">
    <style>
        /* 语言选择 */
        #top {
            background: #eee;
            border-bottom: 1px solid #ddd;
            padding: 0 10px;
            line-height: 40px;
            font-size: 12px;
        }
        /* 日历 */
        #calendar {
            margin: 40px auto;
            padding: 0 10px;
            width: 1000px;
        }
        /* Event 参数 className 的值 */
        .done:before {
            content: "【 已完成 】";
            background-color: yellow;
            color: green;
            text-align: center;
            font-weight: bold;
            width: 100%;
        }
        /* Event 参数 className 的值 */
        .doing:before {
            content: "【 未完成 】";
            background-color: yellow;
            color: red;
            text-align: center;
            font-weight: bold;
        }


        /*.col-sm-1, .col-sm-2, .col-sm-3, .col-sm-4, .col-sm-5, .col-sm-6, .col-sm-7, .col-sm-8, .col-sm-9, .col-sm-10, .col-sm-11, .col-sm-12,
        .col-xs-1, .col-xs-2, .col-xs-3, .col-xs-4, .col-xs-5, .col-xs-6, .col-xs-7, .col-xs-8, .col-xs-9, .col-xs-10, .col-xs-11, .col-xs-12,
        .btn-group,.ibox-content,.panel-body {
            border-style: solid;
            border-width: 1px;
            border-color: #000;
        }*/
        .ibox-content {
            padding-top: 0px;
        }

        .ibox {
            padding-top: 0px;
        }

        .laber {
            padding-left: 0px;
            padding-right: 0px;
            margin-top: 26px;
        }

        .select {
            padding-left: 0px;
            padding-right: 0px;
            margin-top: 18px;
        }

        .btm {
            padding: 0px;
        }
    </style>
</head>

<body class="gray-bg">

    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="ibox float-e-margins">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <strong>查询条件</strong>
                </div>
                <div class="panel-body btm">
                    <div class="col-sm-12" style="margin-bottom:0px;">
                        <div class="form-group col-sm-2">
                            <label class="col-xs-3 control-label laber">部门：</label>
                            <div class="col-xs-9 select">
                                <select class="form-control" name="Department" id="Department">
                                    <option value="0">部门</option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group col-sm-2">
                            <label class="col-xs-3 control-label laber">公司人员:</label>
                            <div class="col-xs-9 select">
                                <select class="form-control" name="Staff" id="Staff">
                                    <option value="">公司人员</option>
                                </select>
                            </div>
                        </div>

                        <div class="form-group col-sm-2">
                            <label class="col-xs-3 control-label laber">月份：</label>
                            <div class="col-xs-9 select">
                                <select class="form-control" name="Month" id="Month">
                                    @for (int i = 0; i < 6; i++)
                                    {
                                        <option value="@DateTime.Now.AddMonths(-i).ToString("yyyy-MM-dd")">@DateTime.Now.AddMonths(-i).ToString("MM月")</option>
                                    }
                                </select>
                            </div>
                        </div>
                        <button id="Search" name="Search" type="button" class="btn btn-primary" onclick="select()" style="margin-top: 18px;">
                            查询
                        </button>
                    </div>
                </div>

            </div>
            <div class="ibox-content">
                @*<table id="table" data-mobile-responsive="true"></table>*@
                <div id='calendar'></div>
            </div>
        </div>
    </div>



    <script src="~/Scripts/bootstrap.js"></script>
    <!-- 全局js -->
    <script src="~/Scripts/jquery.min.js?v=2.1.4"></script>
    <script src="~/Scripts/bootstrap.min.js?v=3.3.6"></script>



    <!-- 自定义js -->
    <script src="~/Scripts/content.js?v=1.0.0"></script>


    <script src="~/Scripts/jquery-ui.custom.min.js"></script>

    <!-- iCheck -->
    <script src="~/Scripts/plugins/iCheck/icheck.min.js"></script>    
    <!-- layer javascript -->
    <script type="text/javascript" src="~/Scripts/plugins/layer/layer.min.js"></script>

    <!-- Full Calendar -->
    <script src="~/Scripts/plugins/fullcalendar/fullcalendar.min.js?v1.0"></script>

    <script type="text/javascript">

        $(function () {
            $('#calendar').hide();
            initCalendar();

        });
        function initCalendar() { 
            //初始化FullCalendar
            $('#calendar').fullCalendar({
                //header:false,
                header: {
                    //left: 'prev,next',
                    //center: 'title',
                    right: ''
                },
                editable: true,
                droppable: true, // this allows things to be dropped onto the calendar !!!
                drop: function (date, allDay) { // this function is called when something is dropped

                    // retrieve the dropped element's stored Event Object
                    var originalEventObject = $(this).data('eventObject');

                    // we need to copy it, so that multiple events don't have a reference to the same object
                    var copiedEventObject = $.extend({}, originalEventObject);

                    // assign it the date that was reported
                    copiedEventObject.start = date;
                    copiedEventObject.allDay = allDay;

                    // render the event on the calendar
                    // the last `true` argument determines if the event "sticks" (http://arshaw.com/fullcalendar/docs/event_rendering/renderEvent/)
                    $('#calendar').fullCalendar('renderEvent', copiedEventObject, true);

                    // is the "remove after drop" checkbox checked?
                    if ($('#drop-remove').is(':checked')) {
                        // if so, remove the element from the "Draggable Events" list
                        $(this).remove();
                    }

                },
                //日程数据
                events: function (start,end,callback) {
                    $.ajax({
                        url: '/Organization/InSide/IndexAsync',
                        type:'post',
                        data: {
                                    Staff: $('#Staff').val(),
                                    Month: $('#Month').val(),
                        },
                        dataType: 'json',
                        success: function (data) { 
                            var dateTime = new Date($('#Month').val());
                            //var d = date.getDate();
                            var m = dateTime.getMonth();
                            var y = dateTime.getFullYear();

                            var events = [];
                            for (var i = 0; i < data.total; i++) { 
                                events.push({
                                    id: data.rows[i].inSideId,//获取当前考勤ID 
                                    title: data.rows[i].startLeaveType == 0 ? '' : data.rows[i].startTime,
                                    start: new Date(y, m, new Date(data.rows[i].createdTime).getDate(), 08, 30),//考勤显示开始时间
                                    className: '上班',
                                    color: data.rows[i].startLeaveType != 1 ? 'red' : 'green'//判断颜色
                                }, {
                                    id: data.rows[i].inSideId,//获取当前考勤ID 
                                    title: data.rows[i].endLeaveType == 0 ? '' : data.rows[i].endTime,
                                    start: new Date(y, m, new Date(data.rows[i].createdTime).getDate(), 17, 30),//考勤显示开始时间
                                    className: '下班',
                                    color: data.rows[i].endLeaveType != 1 ? 'red' : 'green'//判断颜色
                                });
                            }
                            callback(events);
                        }
                    });
                },
                eventClick: function (event, jsEvent, view) {
                    if (event.className == '上班') { 
                        parent.layer.open({
                            type: 2,
                            title: '上班考勤图片',
                            shadeClose: true,
                            shade: 0.4,
                            area: ['520px', '450px'],
                            content: '/Organization/InSide/SratImage?id=' + event.id + '&count=' + 1,
                            end: function () {
                                //refreshTable();
                            }
                        });
                    } if (event.className == '下班') {
                        parent.layer.open({
                            type: 2,
                            title: '下班考勤图片',
                            shadeClose: true,
                            shade: 0.4,
                            area: ['520px', '450px'],
                            content: '/Organization/InSide/SratImage?id=' + event.id + '&count=' + 2,
                            end: function () {
                                //refreshTable();
                            }
                        });
                    }
                }
            });
        } 
        function select() { 
            if ($('#calendar').hide()) { 
                $('#calendar').show();
            }
             
            if ($('#Staff').val()=='') {
                layer.msg("请选择考勤人员", { icon: 5, time: 2000 });
                return;
            }
            //刷新日历数据
            var dateTime = new Date($('#Month').val());
            var fcsYear = dateTime.getFullYear();
            var fcsMonth = dateTime.getMonth()+1;
            $('#calendar').fullCalendar('gotoDate', fcsYear, fcsMonth);

            var dateTime1 = new Date($('#Month').val());
            var fcsYear1 = dateTime.getFullYear();
            var fcsMonth1 = dateTime.getMonth();
            $('#calendar').fullCalendar('gotoDate', fcsYear1, fcsMonth1);
        }
        GetDepartment();
        $("#Department").change(function () { GetStaff() });
        function GetDepartment() {
            $("#Department").empty();//清空部门SELECT控件
            $.getJSON("/Organization/InSide/GetDepartmentlist", function (data) {
                $("<option></option>").val("0").text("总公司").appendTo($("#Department"));
                $.each(data, function (i, item) {
                    $("<option></option>").val(item["id"]).text(item["name"]).appendTo($("#Department"));
                })
                GetStaff();
            });
        }
        function GetStaff() {
            $("#Staff").empty();//清空人员SELECT控件
            $.getJSON(
            "/Organization/InSide/GetStafflist",
            { did: $("#Department").val() },
            function (data) {
                $("<option></option>").val("").text("全部").appendTo($("#Staff"));
                $.each(data, function (i, item) {
                    $("<option></option>").val(item["id"]).text(item["name"]).appendTo($("#Staff"));
                })
            });
        } 
    </script>
    <script type="text/javascript" src="http://tajs.qq.com/stats?sId=9051096" charset="UTF-8"></script>
    <!--统计代码，可删除-->

</body>

</html>
